Repository navigation
fix: comment limit is 29 UTF-16 units, as the MetaTrader5 package enforces - #15
Merged
Merged
Conversation
…orces Measured on a demo account with order_check (sends nothing), MetaTrader5 5.0.6231: 29 UTF-16 units pass, 30 get [-2] Invalid "comment" argument, for ASCII, Polish, CJK and emoji alike; "\U0001f680" * 15 (15 characters, 30 units) is refused, so len() was the wrong measure. The documented 31 let 30-31 through to a TERMINAL_ERROR that hid the cause. A comment that is not str is refused as INVALID_ARGUMENT: `comment or ""` stored 0 or False as an empty comment without a word. tests/integration re-measures the boundary against the installed package with order_check and asserts the refusal is the comment error (-2), so a package that moves the limit fails there. RED: test_orders (30 units, emoji, non-str) and test_failure_paths failed against the old limit; the integration boundary test failed with MAX_COMMENT_LENGTH = 31 (2 of 4 cases). Renamed tests test_comment_within_terminal_limit_is_kept and test_comment_over_terminal_limit_is_rejected_not_truncated. Repo-wide grep (excluding .venv/.git): matches only in .pytest_cache/.mypy_cache.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Goal
The first run of
pytest -m integrationon a demo account (MetaQuotes-Demo, MetaTrader5 5.0.6231) showed that the comment limit in 3.0 was wrong. The library let 30–31 characters through, but theMetaTrader5package refuses them with[-2] Invalid "comment" argument. The caller got a genericTERMINAL_ERRORinstead ofINVALID_ARGUMENT. Nothing was sent.What changed
order_check, which sends nothing."🚀" * 15(15 characters, 30 units) is refused, solen()was the wrong measure.commentthat is not astris refused asINVALID_ARGUMENT. Before,comment or ""turned0/Falseinto an empty comment without a word.order_checkand asserts that the refusal is the comment error (-2), so a package that moves the limit fails it. Verified: with the documented 31 it fails 2 of 4 cases.Demo-account verification (the three open questions from #14)
positions_get/orders_get:()withlast_errorSuccessfor an empty result, andNonewith-4 Not foundfor an unknown symbol. The adapter already maps these toOk([])andErr.Verification
312 tests pass, 99% coverage. ruff, ruff format, mypy --strict and the file-length check are clean.
On the demo account,
pytest -m integrationpasses 7 of 7.Two
/code-review highrounds. Accepted findings:-2comment error;objectparameter type.Refuted by measurement: the claim that a lone surrogate raises
UnicodeEncodeError.Named debt (not fixed here)
MetaTrader5dependency is not pinned. A build that moves the limit would make us refuse valid comments (30–31) or let invalid ones through toTERMINAL_ERROR. Neither case sends a bad order. The integration test detects the drift, but only where someone runs it with a demo account._send_failuremaps-2(RES_E_INVALID_PARAMS) toTERMINAL_ERROR. Every argument the package refuses is therefore misclassified, not only the comment. A separate change, because it touches the not-sent / outcome-unknown classification.MAX_COMMENT_LENGTHis not public API.Semgrep
Re-checked by CI on this push.